package com.zyf.larklaunch.v1;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 根据业务功能标识（feature key），快速查询灰度规则（DarkFeature）
 * @author yifeng
 */
public class DarkRule {
    private Map<String, DarkFeature> darkFeatures = new HashMap<>();

    public DarkRule(DarkRuleConfig darkRuleConfig) {
        List<DarkRuleConfig.DarkFeatureConfig> features = darkRuleConfig.getFeatures();
        for (DarkRuleConfig.DarkFeatureConfig feature : features) {
            darkFeatures.put(feature.getKey(), new DarkFeature(feature));
        }
    }

    public DarkFeature getDarkFeature(String featureKey) {
        return darkFeatures.get(featureKey);
    }
}
